/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
//
//
*/

#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_ENCODER)

#include "umc_avs_enc_slice.h"

namespace UMC
{

AVSEncSlice::AVSEncSlice(void)
{
    memset(&m_disCtx, 0, sizeof(m_disCtx));
    memset(&m_meCtx, 0, sizeof(m_meCtx));

} // AVSEncSlice::AVSEncSlice(void)

AVSEncSlice::~AVSEncSlice(void)
{
    memset(&m_disCtx, 0, sizeof(m_disCtx));
    memset(&m_meCtx, 0, sizeof(m_meCtx));

} // AVSEncSlice::~AVSEncSlice(void)

Status AVSEncSlice::Reset(const AVS_SEQUENCE_HEADER *pSeqHeader,
                          const AVS_PICTURE_HEADER *pPicHeader)
{
    Status umcRes;

    // call the parent's method
    umcRes = AVSSlice::Reset(pSeqHeader, pPicHeader);
    if (UMC_OK != umcRes)
        return umcRes;

    // initialize disassembling context
    memset(&m_disCtx, 0, sizeof(AVS_DISASSEMBLING_CONTEXT));
    m_disCtx.MbFirst = m_SlcHeader.first_mb;
    m_disCtx.MbIndex = m_SlcHeader.first_mb;
    m_disCtx.MbWidth = m_decCtx.MbWidth;
    m_disCtx.MbHeight = m_decCtx.MbHeight;
    m_disCtx.MbLast = m_decCtx.MbLast;
    m_disCtx.FixedQP = m_decCtx.FixedQP;
    m_disCtx.PreviousQP = m_decCtx.PreviousQP;

    m_disCtx.iNumberOfBlocks = m_decCtx.iNumberOfBlocks;
    m_disCtx.isSecondField = m_decCtx.isSecondField;
    m_disCtx.m_pSlice = this;
    m_disCtx.m_pPicHeader = pPicHeader;
    m_disCtx.m_pSeqHeader = pSeqHeader;
    m_disCtx.m_pSlcHeader = &m_SlcHeader;
    m_disCtx.MbX = 0;
    m_disCtx.MbY = m_decCtx.MbY;
    m_disCtx.MbY = m_decCtx.MbY;

    // init ME context
    //memset(&m_meCtx, 0, sizeof(AVS_ME_CONTEXT)); // done in constructor
    m_meCtx.MbFirst = m_SlcHeader.first_mb;
    m_meCtx.MbIndex = m_SlcHeader.first_mb;
    m_meCtx.MbWidth = m_decCtx.MbWidth;
    m_meCtx.MbHeight = m_decCtx.MbHeight;
    m_meCtx.MbLast = m_decCtx.MbLast;
    m_meCtx.FixedQP = m_decCtx.FixedQP;
    m_meCtx.PreviousQP = m_decCtx.PreviousQP;

    m_meCtx.iNumberOfBlocks = m_decCtx.iNumberOfBlocks;
    m_meCtx.isSecondField = m_decCtx.isSecondField;
    m_meCtx.m_pSlice = this;
    m_meCtx.m_pPicHeader = pPicHeader;
    m_meCtx.m_pSeqHeader = pSeqHeader;
    m_meCtx.m_pSlcHeader = &m_SlcHeader;
    m_meCtx.MbX = 0;
    m_meCtx.MbY = m_decCtx.MbY;
    m_meCtx.MbY = m_decCtx.MbY;
    m_meCtx.m_meMask = 0;
    m_bMeVacant = true;

    return UMC_OK;

} // Status AVSEncSlice::Reset(const AVS_SEQUENCE_HEADER *pSeqHeader,

} // namespace UMC

#endif // defined(UMC_ENABLE_AVS_VIDEO_ENCODER)
